<template>
  <div class="needNotes">
    <div class="title_line">
      <div class="title_img">
        <img src="@/assets//images/demand.png" alt="" />
      </div>
      <p >需求信息</p>
    </div>
    <el-form
      ref="neekWorksFormOne"
      :model="neekWorksForm"
      :rules="neekWorksFormRules"
      label-width="auto"
      class="demo-neekWorksForm"
      :size="formSize"
      status-icon
      label-position="top"
    >
      <el-form-item label="岗位需求描述" prop="requireJobOverview">
        <el-input
          placeholder="请输入岗位需求描述"
          v-model="neekWorksForm.requireJobOverview"
          type="textarea"
          :autosize="{ minRows: 5, maxRows: 5 }"
          maxlength="300"
          show-word-limit
        />
      </el-form-item>
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="需求申请人" prop="requireProposerName">
            <el-input
              v-model="neekWorksForm.requireProposerName"
              type="input"
              :disabled="true"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="需求部门" prop="requireDeptId">
            <el-select
              v-model="neekWorksForm.requireDeptId"
              clearable
              placeholder="请选择需求部门"
              @change="requireDeptIdChange"
            >
              <el-option
                v-for="item in buIdOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="申请时间" prop="proposeTime">
            <el-input
              type="input"
              v-model="neekWorksForm.proposeTime"
              :disabled="true"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="HR" prop="hrId">
            <el-select
              v-model="neekWorksForm.hrId"
              clearable
              placeholder="请选择HR"
            >
              <el-option
                v-for="item in hrNameOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script setup>
const props = defineProps({
  neekWorksForm: Object,
  neekWorksFormRules: Object,
  formSize: String,
  buIdOptions: Array,
  hrNameOptions: Array,
});

const emit = defineEmits(["dept-change", "hr-change", "update:formData"]);
const neekWorksFormOne = ref(null);
// console.log(buIdOptions,'buIdOptions')
const validate = () => {
  return neekWorksFormOne.value.validate();
};

// 暴露重置方法
const resetFields = () => {
  neekWorksFormOne.value.resetFields();
};

// 部门切换
const requireDeptIdChange = (val) => {
  //...原有逻辑
  emit("dept-change", val);
};

defineExpose({
  validate,
  resetFields,
});
</script>
<style></style>
